<template>
  <div>
    <!--  AE从速卖通获取指定订单  -->
    <el-dialog title="AE从速卖通获取指定订单" :visible.sync="open" width="500px" @close="close">
      <el-form :model="form" :rules="rules" ref="formRef" size="small"
               label-width="120px">
        <el-form-item label="选择店铺：" prop="storeId">
          <el-select v-model="form.storeId" placeholder="请选择店铺">
            <el-option v-for="(item,index) in storeList" :key="index" :label="item.storeName || item.lable"
                       :value="item.value || item.storeId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单号：" prop="orderId">
          <el-input v-model="form.orderId" placeholder="该方式只能获取单个订单"
                    clearable/>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {queryOrderFromAeByOrderId} from "@/api/order/orderApi"

export default {
  name: 'order-list',
  props: {
    storeList: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      open: true,
      form: {},//国内运单号信息
      rules: { // 线上发货表单校验
        storeId: [{required: true, message: '请选择店铺', trigger: 'change'}],
        orderId: [{required: true, message: '订单号不能为空', trigger: 'blur'}],
      },
    }
  },
  mounted() {

  },
  methods: {
    // 确定提交
    confirm() {
      this.$refs['formRef'].validate((valid) => {
        if (valid) {
          queryOrderFromAeByOrderId(this.form).then(res => {
            this.$message.success(res.msg)
            this.close('1')
          })
        }
      })
    },
    // 关闭线上发货弹窗
    close(e) {
      this.$emit('close', e)
    },
  }
}
</script>
<style scoped>
.el-divider__text {
  font-size: 16px;
  font-weight: bold;
  color: #000;
}
</style>
